#include<iostream>
using namespace std;
ModifiedBinarySearch (int*A, int n, int x, int M)
{
	int low=1;
	int high=n;
	int index=0;
	int low_span=0;
	int high_span=0;
    while(low<=high&&low_span>=0&&high_span>=0)
    {
    	low_span=(x-A[low])/M;
    	low=low+A[low_span];
    	high_span= (A[high]-x) /M;
		high=high-A[high_span];
		int mid=A[(low+high)/2];
	if (x=A[mid])
	{ index=mid;
	break;}
	else if(x<A[mid])
	{
	 high=mid-1;
	}
	else
	{
	low=mid+1;
	return index;
	}
	}
}
int main()
{
	int A[17]={1, 4, 5, 7, 8, 9, 10, 12, 15, 18, 19, 22, 24, 27, 30, 32, 35};
	int c=ModifiedBinarySearch (A, 17, 19, 3);
	cout<<c<<endl;
	return 0;
}
 
